package com.boot2.core.utils;

/**
 * @author zhangweilin
 * @Description: 时序数据库降采样工具
 * @date 2020/11/19
 */
public class DownsampleUtil {

    /**
     * 降采样周期，获取分钟
     * @param downsample
     * @return
     */
    public static int getMin(String downsample) {
        int num = 0;
        if (downsample.endsWith("m")) {
            num = Integer.valueOf(downsample.replace("m", ""));
        } else if (downsample.endsWith("h")) {
            num = Integer.valueOf(downsample.replace("h", ""));
            num = num * 60;
        }else if (downsample.endsWith("d")) {
            num = Integer.valueOf(downsample.replace("d", ""));
            num = num * 60 * 24;
        }
        return num;
    }


}
